package com.hazardSoft.eStore.integration;

import java.util.List;

import com.hazardSoft.eStore.common.exception.SystemException;
import com.hazardSoft.eStore.common.integration.EJB3ServiceLocator;
import com.hazardSoft.eStore.ejb.OfferEJB;
import com.hazardSoft.eStore.entities.Offer;
import com.hazardSoft.eStore.interfaces.OfferLocal;
import com.hazardSoft.eStore.utils.PathConstants;

public class OfferDelegate {

	private static final String CLASS_NAME = PathConstants.DELEGATES_PATH+OfferDelegate.class.getSimpleName();
	private OfferLocal offerLocal;
	
	public OfferDelegate () throws SystemException{
		
		try {
			offerLocal = (OfferLocal) EJB3ServiceLocator.getLocalEJB(OfferEJB.EJB_NAME);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "OfferDelegate");
		}
	}
	
	public Offer insertOffer(Offer offer) throws SystemException {
		
		try {
			return offerLocal.insertOffer(offer);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "insertOffer");
		}
	}

	
	public List<Offer> listOffers() throws SystemException {
		
		try {
			return offerLocal.listOffers();
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "listOffers");
		}
	}

	
	public boolean removeOffer(Offer offer) throws SystemException {
		
		try {
			return offerLocal.removeOffer(offer);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "removeOffer");
		}
	}

	
	public Offer searchOfferById(Offer offer) throws SystemException {
		
		try {
			return offerLocal.searchOfferById(offer);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "searchOfferById");
		}
	}

	
	public Offer searchOfferByName(Offer offer) throws SystemException {
	
		try {
			return offerLocal.searchOfferByName(offer);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "searchOfferByName");
		}
	}

	
	public Offer updateOffer(Offer offer) throws SystemException {
		
		try {
			return offerLocal.updateOffer(offer);
		} catch (Exception e) {
			throw new SystemException(e, CLASS_NAME, "updateOffer");
		}
	}

}
